﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using log4net;

namespace DingHeng.TransportationManagement.WebCommon.Extension
{
    public static class ObjectExtension
    {
        /// <summary>
        /// 记录错误日志，此错误一般是影响系统功能的错误
        /// </summary>
        /// <param name="errorMessage">错误信息</param>
        /// <param name="ex">异常实例</param>
        public static void LogError(this object obj, string errorMessage, Exception ex)
        {
            LogManager.GetLogger("Transportation").Error(errorMessage, ex);
        }
        /// <summary>
        /// 记录错误日志，此错误一般是影响系统功能的错误
        /// </summary>
        /// <param name="errorMessage">错误信息</param>
        public static void LogError(this object obj, string errorMessage)
        {
            LogManager.GetLogger("Transportation").Error(errorMessage);
        }
        /// <summary>
        /// 记录警告信息
        /// </summary>
        /// <param name="warnMessage">警告消息</param>
        /// <param name="ex">异常实例</param>
        public static void LogWarn(this object obj, string warnMessage, Exception ex)
        {
            LogManager.GetLogger("Transportation").Warn(warnMessage, ex);
        }
        /// <summary>
        /// 记录警告信息
        /// </summary>
        /// <param name="warnMessage">警告消息</param>
        public static void LogWarn(this object obj, string warnMessage)
        {
            LogManager.GetLogger("Transportation").Warn(warnMessage);
        }
        /// <summary>
        /// 记录消息级别的信息
        /// </summary>
        /// <param name="infoMessage">信息</param>
        public static void LogInfo(this object obj, string infoMessage)
        {
            LogManager.GetLogger("Transportation").Info(infoMessage);
        }
        /// <summary>
        /// 记录调试级别的信息
        /// </summary>
        /// <param name="debugMessage">调试级别信息</param>
        public static void LogDebug(this object obj, string debugMessage)
        {
            LogManager.GetLogger("Transportation").Debug(debugMessage);
        }
        ///// <summary>
        ///// 记录
        ///// </summary>
        ///// <param name="fatalMessage"></param>
        //public static void LogFatal(string fatalMessage)
        //{
        //    LogManager.GetLogger("Transportation").Fatal(fatalMessage);
        //}
    }
}
